package com.qxl.forest.business.persistence.dao;

import com.qxl.forest.business.persistence.entity.Dept;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: qiuxinlin
 * @Dercription:
 * @Date: 19:17 2017/11/23
 */
@Repository
public interface DeptDao extends PagingAndSortingRepository<Dept, Integer> {

    /**
     * 通过pid查找部门
     *
     * @param pid
     * @return
     */
    List findByPid(Integer pid);

    /**
     * 通过pid查询子部门ids
     *
     * @param pid
     * @return
     */
    @Query(value = "SELECT id FROM f_dept WHERE pid=?1", nativeQuery = true)
    List findIdsByPid(Integer pid);
}
